<!--
对象创建：
   1. 通过字面量创建 

   2. 使用 new object 创建对象

   3. 使用构造函数
-->

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>

<script>
    // 1.
    let a={};
    let student={
        name:"乐",
        height:167,
        weight:97,
        sayHello:function(){
            console.log("乐，你好呀");
        }
    }

    console.log(student.name);
    console.log(student['height']);// 括号内必须是字符
    console.log(student['weight']);
    student.sayHello;

    // 2. 
    let student2=new Object();
    student2.name="佳乐";
    student2.weight=97;
    student2['height']=168;
    student2.SayHello=function(){
        console.log(student2.name+"hello")
    }
    
    console.log(student2.name);
    console.log(student2['height']);

    // 3. 构造函数
    function People(name, height,weight){
        this.name=name;
        this.weight=weight;
        this.height=height;
        this.Say=function(){
            console.log(this.name+"你好呀");
        }
    }

    let le=new People("le",168,98);
    console.log(le.height);
    le.Say();
</script>
</html>